package com.szewec.ps.ui.road.facilities.intersection.task;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;

import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.szewec.ps.R;
import com.szewec.ps.base.BaseActivity;
import com.szewec.ps.base.BaseMediaPickerActivity;
import com.szewec.ps.base.Constants;
import com.szewec.ps.base.FileUpload;
import com.szewec.ps.databinding.ActivityEntranceRoadBinding;
import com.szewec.ps.model.PresentValue;
import com.szewec.ps.model.ViewModeValue;
import com.szewec.ps.model.response.ResponseData;
import com.szewec.ps.myinterface.BindEditTextViewValue;
import com.szewec.ps.myinterface.CallBackInterface;
import com.szewec.ps.myview.TitleViewWithAdd;
import com.szewec.ps.myview.toast.bamtoast.BamToast;
import com.szewec.ps.ui.road.facilities.intersection.task.templete.ImportOptionsDialog;
import com.szewec.ps.ui.road.facilities.intersection.task.constants.Consts;
import com.szewec.ps.ui.road.facilities.intersection.task.enums.RoadEnums;
import com.szewec.ps.ui.road.facilities.intersection.task.model.BicycleLane;
import com.szewec.ps.ui.road.facilities.intersection.task.model.CenterDivider;
import com.szewec.ps.ui.road.facilities.intersection.task.model.DirectionIsland;
import com.szewec.ps.ui.road.facilities.intersection.task.model.EntranceRoad;
import com.szewec.ps.ui.road.facilities.intersection.task.model.Gateway;
import com.szewec.ps.ui.road.facilities.intersection.task.model.RoadHierarchy;
import com.szewec.ps.ui.road.facilities.intersection.task.model.IntersectionTask;
import com.szewec.ps.ui.road.facilities.intersection.task.model.Sidewalk;
import com.szewec.ps.ui.road.facilities.intersection.task.model.SlowLane;
import com.szewec.ps.ui.road.facilities.intersection.task.model.VehicleLane;
import com.szewec.ps.ui.road.facilities.intersection.task.model.WaitingArea;
import com.szewec.ps.ui.road.facilities.intersection.task.model.WeavingSection;
import com.szewec.ps.ui.road.facilities.intersection.task.model.Widen;
import com.szewec.ps.ui.road.facilities.intersection.task.utils.BeanUtils;
import com.szewec.ps.ui.road.facilities.intersection.task.utils.ViewUtils;
import com.szewec.ps.util.CommonUtils;
import com.szewec.ps.util.GsonUtil;
import com.szewec.ps.util.LogUtil;
import com.szewec.ps.util.RollUtil;
import com.szewec.ps.util.StringUtils;
import com.szewec.ps.util.TextViewUtil;
import com.szewec.ps.util.dialog.LoadingDialog;
import com.szewec.ps.util.imagepicker.adapter.CustomPickerAdapterShowAndEdit;
import com.szewec.ps.util.imagepicker.data.MediaFile;
import com.szewec.ps.util.okhttp.OkHttp;

import org.apache.commons.collections4.CollectionUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.ButterKnife;

import static com.szewec.ps.ui.road.facilities.intersection.task.constants.Consts.Type;

public class EntranceRoadActivity extends BaseMediaPickerActivity implements BindEditTextViewValue {

    private final String TAG = "EntranceRoadActivity";

    private ActivityEntranceRoadBinding binding;
    private String flag;
    private IntersectionTask intersectionTask;
    private List<RoadHierarchy> roadHierarchyList = new ArrayList<>();
    private List<String> importRoadNumList = new ArrayList<>();

    //方向
    private List<String> directionList = new ArrayList<>();

    private List<String> roadNames = new ArrayList<>();
    private List<String> roadLevels = new ArrayList<>();
    private int junctionType;

    //当前页面的实体
    private EntranceRoad entranceRoad = new EntranceRoad();
    //所有已经保存的实体
//    private List<EntranceRoad> entranceRoadList = new ArrayList<>();

    //进口道对象
    private VehicleLane vehicleLane = new VehicleLane();
    //出口道对象
    private VehicleLane exitLane = new VehicleLane();
    //进口道展宽对象
    private Widen importWiden = new Widen();
    //出口道展宽对象
    private Widen exitWiden = new Widen();
    //中央分隔带对象
    private CenterDivider centerDivider = new CenterDivider();
    //人行横道带对象
    private Sidewalk sidewalk = new Sidewalk();
    //非机动车道带对象
    private BicycleLane bicycleLane = new BicycleLane();
    //待行区对象
    private WaitingArea waitingArea = new WaitingArea();
    //慢行道对象
    private SlowLane slowLane = new SlowLane();
    //交织段对象
    private WeavingSection weavingSection = new WeavingSection();
    //方向岛对象
    private DirectionIsland directionIsland = new DirectionIsland();
    //左转闸道
    private Gateway leftGateway = new Gateway();
    //右转闸道
    private Gateway rightGateway = new Gateway();

    // 照片上传数组
    private List<String> photoSketchUploadIdArr = new ArrayList<>();
    // 照片文件数组
    private ArrayList<MediaFile> photoSketchFileArr = new ArrayList<>();
    // 图片适配器
    private CustomPickerAdapterShowAndEdit photoSketchAdapter;
    // 移除的图片ID数组
    private List<String> deletePhotoIdArr = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.activity_entrance_road);
        ButterKnife.bind(this);

        Bundle presentValue = getIntent().getExtras();
        PresentValue<Map<String, Object>> value = (PresentValue<Map<String, Object>>) presentValue.getSerializable(Constants.EXTRA_KEY.ENTRANCE_ROAD);
        flag = value.getFlag();
        intersectionTask = (IntersectionTask) value.getT().get("intersectionTask");
        junctionType = intersectionTask.getJunctionType();
        if (Constants.PRESENT_VALUE_FLAG.ADD.equals(flag)) {
            addInitView();
            initSelect();
        } else if (Constants.PRESENT_VALUE_FLAG.EDIT.equals(flag)) {
            entranceRoad = (EntranceRoad) value.getT().get("entranceRoad");
            initDataToView();
        }
        entranceRoad.setIntersectionTaskId(intersectionTask.getId());
        initTitleBar();
        initInputView();
        initChildData();
        initChildJump();
        // 显示附件内容
        initViewFile();
    }

    private void initTitleBar() {
        ViewModeValue viewModeValue = new ViewModeValue(this, Constants.PRESENT_VALUE_FLAG.ADD, binding.titleBar, binding.llContainer);
        if (flag.equals(Constants.PRESENT_VALUE_FLAG.EDIT)) {
            viewModeValue.setMode(Constants.PRESENT_VALUE_FLAG.VIEW_ONE);
        }
        //设置导航栏右侧按钮
        CommonUtils.setViewMode(viewModeValue, this::finish, () -> {
            switch (flag) {
                case Constants.PRESENT_VALUE_FLAG.ADD:
                    saveData();
                    break;
                case Constants.PRESENT_VALUE_FLAG.EDIT:
                    CommonUtils.showMoreMenu(this, binding.titleBar.getRightLayout(), () -> {
                        viewModeValue.setMode(flag);
                        initSelect();
                        binding.itImportRoadNum.switchoverMode(false);
                        CommonUtils.setViewMode(viewModeValue, this::finish, this::putData);
                    }, this::delData);
                    break;
            }
        });
    }

    private void saveData() {
        RoadHierarchy roadHierarchy = new RoadHierarchy();
        roadHierarchy.setRoadName(binding.itRoadName.getStringValue());
        roadHierarchy.setRoadLevel(binding.itRoadLevel.getStringValue());
        entranceRoad.setRoadHierarchy(JSON.toJSONString(roadHierarchy));
        entranceRoad.setImportRoadNum(binding.itImportRoadNum.getStringValue());
        entranceRoad.setImportRoadDirection(binding.itImportRoadDirection.getStringValue());
        entranceRoad.setAddIds(photoSketchUploadIdArr);
        entranceRoad.setRemoveIds(deletePhotoIdArr);

        OkHttp.post("/tpms-plan-service/api/entrance-road", entranceRoad, result -> {
            ResponseData responseData = JSON.parseObject(result, ResponseData.class);
            if (responseData.getCode() == Constants.ResponseCode.SUCCESS) {
                entranceRoad = JSON.parseObject(responseData.getData().toString(), EntranceRoad.class);
                BamToast.showText(this, responseData.getMsg(), true);

                finishForResult(Constants.RESULT_FLAG.INSERT_OR_UPDATE);
            } else {
                BamToast.showText(this, responseData.getMsg(), false);
            }
            LogUtil.i(TAG + "post======>", result);
        });
    }

    //修改数据
    private void putData() {
        RoadHierarchy roadHierarchy = new RoadHierarchy();
        roadHierarchy.setRoadName(binding.itRoadName.getStringValue());
        roadHierarchy.setRoadLevel(binding.itRoadLevel.getStringValue());
        EntranceRoad entranceRoad = new EntranceRoad();
        entranceRoad.setId(this.entranceRoad.getId());
        entranceRoad.setIntersectionTaskId(this.entranceRoad.getIntersectionTaskId());
        entranceRoad.setRoadHierarchy(JSON.toJSONString(roadHierarchy));
        entranceRoad.setImportRoadNum(binding.itImportRoadNum.getStringValue());
        entranceRoad.setImportRoadDirection(binding.itImportRoadDirection.getStringValue());
        entranceRoad.setPosition(this.entranceRoad.getPosition());
        if (BeanUtils.comparisonOutside(entranceRoad, this.entranceRoad)) {
            return;
        }
        this.entranceRoad = entranceRoad;

        OkHttp.put("/tpms-plan-service/api/entrance-road", entranceRoad, result -> {
            ResponseData test = JSON.parseObject(result, ResponseData.class);
            if (test.getCode() == Constants.ResponseCode.SUCCESS) {
                BamToast.showText(this, test.getMsg(), true);

                //带入返回数据
                finishForResult(Constants.RESULT_FLAG.INSERT_OR_UPDATE);
            } else {
                BamToast.showText(this, test.getMsg(), false);
            }
            LogUtil.i(TAG + "post======>", result);
        });
    }

    //删除数据
    private void delData() {
        OkHttp.delete("/tpms-plan-service/api/entrance-road/" + entranceRoad.getId(), result -> {
            ResponseData test = JSON.parseObject(result, ResponseData.class);
            if (test.getCode() == Constants.ResponseCode.SUCCESS) {
                BamToast.showText(this, test.getMsg(), true);

                //带入返回数据
                finishForResult(Constants.RESULT_FLAG.DELETE);
            } else {
                BamToast.showText(this, test.getMsg(), false);
            }
            LogUtil.i(TAG + "post======>", result);
        });
    }

    //加载下拉框的选项
    private void initSelect() {
        roadHierarchyList = intersectionTask.getRoadHierarchies();
        for (RoadHierarchy l : roadHierarchyList) {
            roadNames.add(l.getRoadName());
            roadLevels.add(l.getRoadLevel());
        }
        binding.itRoadName.setSelectTypeClickListener(v -> {
            TextViewUtil.closeKeyboard(this);
            RollUtil.alertBottomWheelOption(this, roadNames, binding.itRoadName.getSelectTextView(), (view, index) -> {
                binding.itRoadName.setValue(roadNames.get(index));
                binding.itRoadLevel.setValue(roadLevels.get(index));
            });
        });
        directionList = Arrays.asList(getResources().getStringArray(R.array.direction));
        binding.itImportRoadDirection.setSelectTypeClickListener(v -> {
            TextViewUtil.closeKeyboard(this);
            RollUtil.alertBottomWheelOption(this, directionList, binding.itImportRoadDirection.getSelectTextView(), (view, index) ->
                    binding.itImportRoadDirection.setValue(directionList.get(index)));
        });
    }

    /**
     * 关闭页面并返回数据
     *
     * @param flag 页面事件
     */
    public void finishForResult(String flag) {
        //带入返回数据
        Intent intent = new Intent();
        PresentValue<EntranceRoad> presentValue = new PresentValue<>(flag, this.entranceRoad);
        intent.putExtra(Constants.EXTRA_KEY.ENTRANCE_ROAD, presentValue);
        setResult(Constants.RESULT_CODE.NEED_REFRESH, intent);
        finish();
    }

    /**
     * 添加数据走的方法
     */
    private void addInitView() {
        Integer importRoadSize = intersectionTask.getImportRoadSize();

        for (int i = 1; i < importRoadSize + 1; i++) {
            importRoadNumList.add("进口" + i);
        }
        binding.itImportRoadNum.setSelectTypeClickListener(v -> {
            TextViewUtil.closeKeyboard(this);
            RollUtil.alertBottomWheelOption(this, importRoadNumList, binding.itImportRoadNum.getSelectTextView(), (view, index) ->
                    binding.itImportRoadNum.setValue(importRoadNumList.get(index)));
        });
    }

    /**
     * 修改数据走的方法
     */
    private void initDataToView() {
        binding.itImportRoadNum.setValue(entranceRoad.getImportRoadNum());
        binding.itImportRoadNum.switchoverMode(false);

        RoadHierarchy hierarchy = JSONObject.parseObject(entranceRoad.getRoadHierarchy(), RoadHierarchy.class);
        binding.itRoadName.setValue(hierarchy.getRoadName());
        System.out.println(entranceRoad.getImportRoadNum());
        binding.itRoadLevel.setValue(hierarchy.getRoadLevel());
        binding.itImportRoadDirection.setValue(entranceRoad.getImportRoadDirection());
    }

    // 设置照片
    private void initViewFile() {
        // 初始化照片适配器
        photoSketchAdapter = initTypeMediaRecyclerView(photoSketchUploadIdArr, photoSketchFileArr,
                binding.photoSketchSketchRV, true, false, true, deletePhotoIdArr);

        // 先根据fileId查询附件数据
        if (!CollectionUtils.isEmpty(entranceRoad.getAddIds())) {
            requestFilesByIds(entranceRoad.getAddIds(), this::initAdapterData);
        }
        // 根据业务ID查询附件信息
        else if (StringUtils.isNotEmpty(entranceRoad.getId())) {
            requestFiles(FileUpload.RoadInvestigationFileBizTypeEnum.ROAD_ENTRANCE_ROAD_FILE_BIZ_TYPE, entranceRoad.getId(), this::initAdapterData);
        }
    }

    // 往照片适配器里面设置图片显示
    private void initAdapterData(List<MediaFile> mediaFileList) {
        if (CollectionUtils.isEmpty(mediaFileList)) {
            return;
        }
        photoSketchUploadIdArr.clear();
        photoSketchFileArr.clear();
        // 添加到文件数组
        photoSketchFileArr.addAll(mediaFileList);
        for (MediaFile mediaFile : photoSketchFileArr) {
            photoSketchUploadIdArr.add(mediaFile.getId());
        }
        // 设置适配器数据源
        photoSketchAdapter.setmMediaFileList(mediaFileList);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (resultCode == RESULT_OK) {
            //拍照返回，或者视频录制返回
            if (isAdapterImagePickerResult(requestCode, photoSketchAdapter)) {
                ArrayList<MediaFile> mediaFileList = getMediaFileListWhenOnActivityResult(requestCode, data, photoSketchAdapter);
                saveFileAndRefreshAdapter(mediaFileList, photoSketchUploadIdArr, photoSketchAdapter,
                        FileUpload.RoadInvestigationFileBizTypeEnum.ROAD_ENTRANCE_ROAD_FILE_BIZ_TYPE);
            }
        }
    }

    private void initInputView() {
        binding.itRoadLevel.switchoverMode(false);

        if (junctionType == (RoadEnums.JunctionType.INTERCHANGE.getKey())) {
            binding.tvaLeftTurnGateway.setVisibility(View.VISIBLE);
            binding.tvaRightTurnGateway.setVisibility(View.VISIBLE);
        } else if (junctionType == (RoadEnums.JunctionType.ROUNDABOUT.getKey())) {
            binding.tvaWeavingSection.setVisibility(View.VISIBLE);
            binding.tvaDirectionIsland.setVisibility(View.VISIBLE);
            binding.tvaBicycleLane.setVisibility(View.VISIBLE);
            binding.tvaSidewalk.setVisibility(View.VISIBLE);
            binding.tvaSlowLane.setVisibility(View.VISIBLE);
        } else {
            binding.tvaImportWiden.setVisibility(View.VISIBLE);
            binding.tvaExitWiden.setVisibility(View.VISIBLE);
            binding.tvaBicycleLane.setVisibility(View.VISIBLE);
            binding.tvaBicycleLane.setTitle("非机动车道");
            binding.tvaSidewalk.setVisibility(View.VISIBLE);
            binding.tvaWaitingArea.setVisibility(View.VISIBLE);
            binding.tvaSlowLane.setVisibility(View.VISIBLE);
        }

        binding.btnCopy.setOnClickListener(v -> {
            final ImportOptionsDialog dialog = new ImportOptionsDialog(EntranceRoadActivity.this);
            dialog.setTitle("选择其他进口道数据").setMList(importRoadNumList)
                    .setOnClickBottomListener(new ImportOptionsDialog.OnClickBottomListener() {
                        @Override
                        public void onDetermineClick() {
                            System.out.println(dialog.getPosition());
                        }

                        @Override
                        public void onCancelClick() {
                            dialog.dismiss();
                        }
                    }).show();
        });
    }

    @Override
    public void setObjValue() {

    }

    @Override
    public boolean checkLinkedDataAndFiles() {
        System.out.println(binding.itImportRoadNum.getStringValue());

        return binding.itImportRoadNum.getStringValue() != null && !binding.itImportRoadNum.getStringValue().equals("");
    }

    //监听滑动
    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            View v = getCurrentFocus();
            if (ViewUtils.isClickNotInView(v, event)) {//点击editText控件外部
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                if (imm != null) {
                    TextViewUtil.closeKeyboard(this);
                    v.clearFocus();
                }
            }
            return super.dispatchTouchEvent(event);
        }
        // 必不可少，否则所有的组件都不会有TouchEvent了
        return getWindow().superDispatchTouchEvent(event) || onTouchEvent(event);
    }

    private int i = 0;

    private void initChildData() {
        LoadingDialog dialog = LoadingDialog.getInstance(this);
        dialog.show();
        switch (junctionType) {
            case Consts.JunctionType.T_Y_INTERSECTION:
            case Consts.JunctionType.CROSSROADS:
            case Consts.JunctionType.MULTI_WAY_INTERSECTION: {
                int size = 9;
                CallBackInterface callBackInterface = () -> {
                    i++;
                    if (i >= size) {
                        dialog.close();
                    }
                };
                getVehicleLane(callBackInterface);
                getExitLane(callBackInterface);
                getImportWiden(callBackInterface);
                getExitWiden(callBackInterface);
                getCenterDivider(callBackInterface);
                getSidewalk(callBackInterface);
                getBicycleLane(callBackInterface);
                getWaitingArea(callBackInterface);
                getSlowLane(callBackInterface);
            }
            break;
            case Consts.JunctionType.ROUNDABOUT: {
                int size = 8;
                CallBackInterface callBackInterface = () -> {
                    i++;
                    if (i >= size) {
                        dialog.close();
                    }
                };
                getVehicleLane(callBackInterface);
                getExitLane(callBackInterface);
                getCenterDivider(callBackInterface);
                getWeavingSection(callBackInterface);
                getDirectionIsland(callBackInterface);
                getSidewalk(callBackInterface);
                getBicycleLane(callBackInterface);
                getSlowLane(callBackInterface);
            }
            break;
            case Consts.JunctionType.INTERCHANGE: {
                int size = 5;
                CallBackInterface callBackInterface = () -> {
                    i++;
                    if (i >= size) {
                        dialog.close();
                    }
                };
                getVehicleLane(callBackInterface);
                getExitLane(callBackInterface);
                getCenterDivider(callBackInterface);
                getLeftGateway(callBackInterface);
                getRightGateway(callBackInterface);
            }
            break;
        }
    }

    private void getVehicleLane(CallBackInterface callBackInterface) {
//        LoadingDialog dialog = LoadingDialog.getInstance(this);
        Map<String, Object> map = new HashMap<>();
        map.put("entranceRoadId", entranceRoad.getId());
        map.put("laneType", Type.IMPORT_LANE);
//        dialog.show();
        //获取进出口道数据
        OkHttp.get("/tpms-plan-service/api/vehicle-lane", map, null, result -> {
            ResponseData res = JSON.parseObject(result, ResponseData.class);
//            switch (res.getCode()) {
//                case Constants.ResponseCode.SUCCESS:
//                    LogUtil.i(TAG + "vehicle-lane=get====>", res.getData().toString());
///*                    List<VehicleLane> ls = GsonUtil.GsonToList(res.getData().toString());
//                    vehicleLane = ls.get(0);*/
//                    vehicleLane = GsonUtil.GsonToListForOne(res.getData().toString(), VehicleLane.class);
////                    vehicleLane = JSON.parseArray(res.getData().toString(), VehicleLane.class).get(0);
//                    binding.tvaImportRoad.setRightType(TitleViewWithAdd.EDIT);
//                    break;
//                case Constants.ResponseCode.DATA_NOT_EXIST:
//                    binding.tvaImportRoad.setRightType(TitleViewWithAdd.ADD);
//                    break;
//            }
            LogUtil.i(TAG + "vehicle-lane=get====>", res.getData().toString());
            if (res.getCode() == Constants.ResponseCode.SUCCESS) {
                if (res.isDataEmpty()) {
                    binding.tvaImportRoad.setRightType(TitleViewWithAdd.ADD);
                } else {
                    vehicleLane = GsonUtil.GsonToListForOne(res.getData().toString(), VehicleLane.class);
                    binding.tvaImportRoad.setRightType(TitleViewWithAdd.EDIT);
                }
            }
            if (callBackInterface != null) {
                callBackInterface.customizedFun();
            }
        });
    }

    private void getExitLane(CallBackInterface callBackInterface) {
//        LoadingDialog dialog = LoadingDialog.getInstance(this);
        Map<String, Object> map = new HashMap<>();
        map.put("entranceRoadId", entranceRoad.getId());
        map.put("laneType", Type.EXIT_LANE);
//        dialog.show();
        //获取进出口道数据
        OkHttp.get("/tpms-plan-service/api/vehicle-lane", map, null, result -> {
            ResponseData res = JSON.parseObject(result, ResponseData.class);
//            switch (res.getCode()) {
//                case Constants.ResponseCode.SUCCESS:
//                    LogUtil.i(TAG + "exit-lane=get====>", res.getData().toString());
//                    exitLane = JSON.parseArray(res.getData().toString(), VehicleLane.class).get(0);
//                    binding.tvaExitRoad.setRightType(TitleViewWithAdd.EDIT);
//                    break;
//                case Constants.ResponseCode.DATA_NOT_EXIST:
//                    binding.tvaExitRoad.setRightType(TitleViewWithAdd.ADD);
//                    break;
//            }
            LogUtil.i(TAG + "exit-lane=get====>", res.getData().toString());
            if (res.getCode() == Constants.ResponseCode.SUCCESS) {
                if (res.isDataEmpty()) {
                    binding.tvaExitRoad.setRightType(TitleViewWithAdd.ADD);
                } else {
                    exitLane = JSON.parseArray(res.getData().toString(), VehicleLane.class).get(0);
                    binding.tvaExitRoad.setRightType(TitleViewWithAdd.EDIT);
                }
            }
            if (callBackInterface != null) {
                callBackInterface.customizedFun();
            }
        });
    }

    //获取进口道展宽数据
    private void getImportWiden(CallBackInterface callBackInterface) {
//        LoadingDialog dialog = LoadingDialog.getInstance(this);
        Map<String, Object> map = new HashMap<>();
        map.put("entranceRoadId", entranceRoad.getId());
        map.put("laneType", Type.IMPORT_WIDEN);
//        dialog.show();

        OkHttp.get("/tpms-plan-service/api/widen", map, null, result -> {
            ResponseData res = JSON.parseObject(result, ResponseData.class);
//            switch (res.getCode()) {
//                case Constants.ResponseCode.SUCCESS:
//                    LogUtil.i(TAG + "widen=get====>", res.getData().toString());
//                    importWiden = GsonUtil.GsonToListForOne(res.getData().toString(), Widen.class);
//                    binding.tvaImportWiden.setRightType(TitleViewWithAdd.EDIT);
//                    break;
//                case Constants.ResponseCode.DATA_NOT_EXIST:
//                    binding.tvaImportWiden.setRightType(TitleViewWithAdd.ADD);
//                    break;
//            }
            LogUtil.i(TAG + "widen=get====>", res.getData().toString());
            if (res.getCode() == Constants.ResponseCode.SUCCESS) {
                if (res.isDataEmpty()) {
                    binding.tvaImportWiden.setRightType(TitleViewWithAdd.ADD);
                } else {
                    importWiden = GsonUtil.GsonToListForOne(res.getData().toString(), Widen.class);
                    binding.tvaImportWiden.setRightType(TitleViewWithAdd.EDIT);
                }
            }
            if (callBackInterface != null) {
                callBackInterface.customizedFun();
            }
        });
    }

    //获取出口道展宽数据
    private void getExitWiden(CallBackInterface callBackInterface) {
//        LoadingDialog dialog = LoadingDialog.getInstance(this);
        Map<String, Object> map = new HashMap<>();
        map.put("entranceRoadId", entranceRoad.getId());
        map.put("laneType", Type.EXIT_WIDEN);
//        dialog.show();

        OkHttp.get("/tpms-plan-service/api/widen", map, null, result -> {
            ResponseData res = JSON.parseObject(result, ResponseData.class);
//            switch (res.getCode()) {
//                case Constants.ResponseCode.SUCCESS:
//                    LogUtil.i(TAG + "widen=get====>", res.getData().toString());
//                    exitWiden = GsonUtil.GsonToListForOne(res.getData().toString(), Widen.class);
//                    binding.tvaExitWiden.setRightType(TitleViewWithAdd.EDIT);
//                    break;
//                case Constants.ResponseCode.DATA_NOT_EXIST:
//                    binding.tvaExitWiden.setRightType(TitleViewWithAdd.ADD);
//                    break;
//            }
            LogUtil.i(TAG + "widen=get====>", res.getData().toString());
            if (res.getCode() == Constants.ResponseCode.SUCCESS) {
                if (res.isDataEmpty()) {
                    binding.tvaExitWiden.setRightType(TitleViewWithAdd.ADD);
                } else {
                    exitWiden = GsonUtil.GsonToListForOne(res.getData().toString(), Widen.class);
                    binding.tvaExitWiden.setRightType(TitleViewWithAdd.EDIT);
                }
            }
            if (callBackInterface != null) {
                callBackInterface.customizedFun();
            }
        });
    }

    private void getCenterDivider(CallBackInterface callBackInterface) {
//        LoadingDialog dialog = LoadingDialog.getInstance(this);
        Map<String, Object> map = new HashMap<>();
        map.put("entranceRoadId", entranceRoad.getId());
//        dialog.show();
        //获取中央分隔带数据
        OkHttp.get("/tpms-plan-service/api/center-divider", map, null, result -> {
            ResponseData res = JSON.parseObject(result, ResponseData.class);
//            switch (res.getCode()) {
//                case Constants.ResponseCode.SUCCESS:
//                    LogUtil.i(TAG + "center-divider=get====>", res.getData().toString());
//                    centerDivider = JSON.parseArray(res.getData().toString(), CenterDivider.class).get(0);
//                    binding.tvaCenterDivider.setRightType(TitleViewWithAdd.EDIT);
//                    break;
//                case Constants.ResponseCode.DATA_NOT_EXIST:
//                    binding.tvaCenterDivider.setRightType(TitleViewWithAdd.ADD);
//                    break;
//            }
            LogUtil.i(TAG + "center-divider=get====>", res.getData().toString());
            if (res.getCode() == Constants.ResponseCode.SUCCESS) {
                if (res.isDataEmpty()) {
                    binding.tvaCenterDivider.setRightType(TitleViewWithAdd.ADD);
                } else {
                    centerDivider = JSON.parseArray(res.getData().toString(), CenterDivider.class).get(0);
                    binding.tvaCenterDivider.setRightType(TitleViewWithAdd.EDIT);
                }
            }
            if (callBackInterface != null) {
                callBackInterface.customizedFun();
            }
        });
    }

    /**
     * 获取人行横道数据
     */
    private void getSidewalk(CallBackInterface callBackInterface) {
//        LoadingDialog dialog = LoadingDialog.getInstance(this);
        Map<String, Object> map = new HashMap<>();
        map.put("entranceRoadId", entranceRoad.getId());
//        dialog.show();
        //获取中央分隔带数据
        OkHttp.get("/tpms-plan-service/api/sidewalk", map, null, result -> {
            ResponseData res = JSON.parseObject(result, ResponseData.class);
//            switch (res.getCode()) {
//                case Constants.ResponseCode.SUCCESS:
//                    LogUtil.i(TAG + "sidewalk=get====>", res.getData().toString());
//                    sidewalk = JSON.parseArray(res.getData().toString(), Sidewalk.class).get(0);
//                    binding.tvaSidewalk.setRightType(TitleViewWithAdd.EDIT);
//                    break;
//                case Constants.ResponseCode.DATA_NOT_EXIST:
//                    binding.tvaSidewalk.setRightType(TitleViewWithAdd.ADD);
//                    break;
//            }
            LogUtil.i(TAG + "sidewalk=get====>", res.getData().toString());
            if (res.getCode() == Constants.ResponseCode.SUCCESS) {
                if (res.isDataEmpty()) {
                    binding.tvaSidewalk.setRightType(TitleViewWithAdd.ADD);
                } else {
                    sidewalk = JSON.parseArray(res.getData().toString(), Sidewalk.class).get(0);
                    binding.tvaSidewalk.setRightType(TitleViewWithAdd.EDIT);
                }
            }
            if (callBackInterface != null) {
                callBackInterface.customizedFun();
            }
        });
    }

    /**
     * 获取非机动车道数据
     */
    private void getBicycleLane(CallBackInterface callBackInterface) {
        Map<String, Object> map = new HashMap<>();
        map.put("entranceRoadId", entranceRoad.getId());
        //获取非机动车道数据
        OkHttp.get("/tpms-plan-service/api/bicycle-lane", map, null, result -> {
            ResponseData res = JSON.parseObject(result, ResponseData.class);
//            switch (res.getCode()) {
//                case Constants.ResponseCode.SUCCESS:
//                    LogUtil.i(TAG + "BicycleLane=get====>", res.getData().toString());
//                    bicycleLane = JSON.parseArray(res.getData().toString(), BicycleLane.class).get(0);
//                    binding.tvaBicycleLane.setRightType(TitleViewWithAdd.EDIT);
//                    break;
//                case Constants.ResponseCode.DATA_NOT_EXIST:
//                    binding.tvaBicycleLane.setRightType(TitleViewWithAdd.ADD);
//                    break;
//            }
            LogUtil.i(TAG + "BicycleLane=get====>", res.getData().toString());
            if (res.getCode() == Constants.ResponseCode.SUCCESS) {
                if (res.isDataEmpty()) {
                    binding.tvaBicycleLane.setRightType(TitleViewWithAdd.ADD);
                } else {
                    bicycleLane = JSON.parseArray(res.getData().toString(), BicycleLane.class).get(0);
                    binding.tvaBicycleLane.setRightType(TitleViewWithAdd.EDIT);
                }
            }
            if (callBackInterface != null) {
                callBackInterface.customizedFun();
            }
        });
    }

    /**
     * 获取待行区数据
     */
    private void getWaitingArea(CallBackInterface callBackInterface) {
        Map<String, Object> map = new HashMap<>();
        map.put("entranceRoadId", entranceRoad.getId());
        //获取非机动车道数据
        OkHttp.get("/tpms-plan-service/api/waiting-area", map, null, result -> {
            ResponseData res = JSON.parseObject(result, ResponseData.class);
//            switch (res.getCode()) {
//                case Constants.ResponseCode.SUCCESS:
//                    LogUtil.i(TAG + "WaitingArea=get====>", res.getData().toString());
//                    waitingArea = JSON.parseArray(res.getData().toString(), WaitingArea.class).get(0);
//                    binding.tvaWaitingArea.setRightType(TitleViewWithAdd.EDIT);
//                    break;
//                case Constants.ResponseCode.DATA_NOT_EXIST:
//                    binding.tvaWaitingArea.setRightType(TitleViewWithAdd.ADD);
//                    break;
//            }
            LogUtil.i(TAG + "WaitingArea=get====>", res.getData().toString());
            if (res.getCode() == Constants.ResponseCode.SUCCESS) {
                if (res.isDataEmpty()) {
                    binding.tvaWaitingArea.setRightType(TitleViewWithAdd.ADD);
                } else {
                    waitingArea = JSON.parseArray(res.getData().toString(), WaitingArea.class).get(0);
                    binding.tvaWaitingArea.setRightType(TitleViewWithAdd.EDIT);
                }
            }
            if (callBackInterface != null) {
                callBackInterface.customizedFun();
            }
        });
    }

    /**
     * 获取慢行道数据
     */
    private void getSlowLane(CallBackInterface callBackInterface) {
        Map<String, Object> map = new HashMap<>();
        map.put("entranceRoadId", entranceRoad.getId());
        //获取非机动车道数据
        OkHttp.get("/tpms-plan-service/api/slow-lane", map, null, result -> {
            ResponseData res = JSON.parseObject(result, ResponseData.class);
//            switch (res.getCode()) {
//                case Constants.ResponseCode.SUCCESS:
//                    LogUtil.i(TAG + "SlowLane=get====>", res.getData().toString());
//                    slowLane = JSON.parseArray(res.getData().toString(), SlowLane.class).get(0);
//                    binding.tvaSlowLane.setRightType(TitleViewWithAdd.EDIT);
//                    break;
//                case Constants.ResponseCode.DATA_NOT_EXIST:
//                    binding.tvaSlowLane.setRightType(TitleViewWithAdd.ADD);
//                    break;
//            }
            LogUtil.i(TAG + "SlowLane=get====>", res.getData().toString());
            if (res.getCode() == Constants.ResponseCode.SUCCESS) {
                if (res.isDataEmpty()) {
                    binding.tvaSlowLane.setRightType(TitleViewWithAdd.ADD);
                } else {
                    slowLane = JSON.parseArray(res.getData().toString(), SlowLane.class).get(0);
                    binding.tvaSlowLane.setRightType(TitleViewWithAdd.EDIT);
                }
            }
            if (callBackInterface != null) {
                callBackInterface.customizedFun();
            }
        });
    }

    /**
     * 获取待行区数据
     */
    private void getWeavingSection(CallBackInterface callBackInterface) {
        Map<String, Object> map = new HashMap<>();
        map.put("entranceRoadId", entranceRoad.getId());
        //获取非机动车道数据
        OkHttp.get("/tpms-plan-service/api/weaving-section", map, null, result -> {
            ResponseData res = JSON.parseObject(result, ResponseData.class);
//            switch (res.getCode()) {
//                case Constants.ResponseCode.SUCCESS:
//                    LogUtil.i(TAG + "weavingSection=get====>", res.getData().toString());
////                    GsonUtil.GsonToListForOne(res.getData().toString(), WeavingSection.class);
//                    weavingSection = GsonUtil.GsonToListForOne(res.getData().toString(), WeavingSection.class);
//                    binding.tvaWeavingSection.setRightType(TitleViewWithAdd.EDIT);
//                    break;
//                case Constants.ResponseCode.DATA_NOT_EXIST:
//                    binding.tvaWeavingSection.setRightType(TitleViewWithAdd.ADD);
//                    break;
//            }
            LogUtil.i(TAG + "weavingSection=get====>", res.getData().toString());
            if (res.getCode() == Constants.ResponseCode.SUCCESS) {
                if (res.isDataEmpty()) {
                    binding.tvaWeavingSection.setRightType(TitleViewWithAdd.ADD);
                } else {
                    weavingSection = GsonUtil.GsonToListForOne(res.getData().toString(), WeavingSection.class);
                    binding.tvaWeavingSection.setRightType(TitleViewWithAdd.EDIT);
                }
            }
            if (callBackInterface != null) {
                callBackInterface.customizedFun();
            }
        });
    }

    /**
     * 获取方向岛数据
     */
    private void getDirectionIsland(CallBackInterface callBackInterface) {
        Map<String, Object> map = new HashMap<>();
        map.put("entranceRoadId", entranceRoad.getId());
        //获取非机动车道数据
        OkHttp.get("/tpms-plan-service/api/direction-island", map, null, result -> {
            ResponseData res = JSON.parseObject(result, ResponseData.class);
//            switch (res.getCode()) {
//                case Constants.ResponseCode.SUCCESS:
//                    LogUtil.i(TAG + "DirectionIsland=get====>", res.getData().toString());
//                    directionIsland = JSON.parseArray(res.getData().toString(), DirectionIsland.class).get(0);
//                    binding.tvaDirectionIsland.setRightType(TitleViewWithAdd.EDIT);
//                    break;
//                case Constants.ResponseCode.DATA_NOT_EXIST:
//                    binding.tvaDirectionIsland.setRightType(TitleViewWithAdd.ADD);
//                    break;
//            }
            LogUtil.i(TAG + "DirectionIsland=get====>", res.getData().toString());
            if (res.getCode() == Constants.ResponseCode.SUCCESS) {
                if (res.isDataEmpty()) {
                    binding.tvaDirectionIsland.setRightType(TitleViewWithAdd.ADD);
                } else {
                    directionIsland = JSON.parseArray(res.getData().toString(), DirectionIsland.class).get(0);
                    binding.tvaDirectionIsland.setRightType(TitleViewWithAdd.EDIT);
                }
            }
            if (callBackInterface != null) {
                callBackInterface.customizedFun();
            }
        });
    }

    //获取左转闸道数据
    private void getLeftGateway(CallBackInterface callBackInterface) {
//        LoadingDialog dialog = LoadingDialog.getInstance(this);
        Map<String, Object> map = new HashMap<>();
        map.put("entranceRoadId", entranceRoad.getId());
        map.put("gatewayType", Type.LEFT_GATEWAY);
//        dialog.show();

        OkHttp.get("/tpms-plan-service/api/gateway", map, null, result -> {
            ResponseData res = JSON.parseObject(result, ResponseData.class);
//            switch (res.getCode()) {
//                case Constants.ResponseCode.SUCCESS:
//                    LogUtil.i(TAG + "leftGateway=get====>", res.getData().toString());
//                    leftGateway = GsonUtil.GsonToListForOne(res.getData().toString(), Gateway.class);
//                    binding.tvaLeftTurnGateway.setRightType(TitleViewWithAdd.EDIT);
//                    break;
//                case Constants.ResponseCode.DATA_NOT_EXIST:
//                    binding.tvaLeftTurnGateway.setRightType(TitleViewWithAdd.ADD);
//                    break;
//            }
            LogUtil.i(TAG + "leftGateway=get====>", res.getData().toString());
            if (res.getCode() == Constants.ResponseCode.SUCCESS) {
                if (res.isDataEmpty()) {
                    binding.tvaLeftTurnGateway.setRightType(TitleViewWithAdd.ADD);
                } else {
                    leftGateway = GsonUtil.GsonToListForOne(res.getData().toString(), Gateway.class);
                    binding.tvaLeftTurnGateway.setRightType(TitleViewWithAdd.EDIT);
                }
            }
            if (callBackInterface != null) {
                callBackInterface.customizedFun();
            }
        });
    }

    //获取右转闸道数据
    private void getRightGateway(CallBackInterface callBackInterface) {
//        LoadingDialog dialog = LoadingDialog.getInstance(this);
        Map<String, Object> map = new HashMap<>();
        map.put("entranceRoadId", entranceRoad.getId());
        map.put("gatewayType", Type.RIGHT_GATEWAY);
//        dialog.show();

        OkHttp.get("/tpms-plan-service/api/gateway", map, null, result -> {
            ResponseData res = JSON.parseObject(result, ResponseData.class);
//            switch (res.getCode()) {
//                case Constants.ResponseCode.SUCCESS:
//                    LogUtil.i(TAG + "rightGateway=get====>", res.getData().toString());
//                    rightGateway = GsonUtil.GsonToListForOne(res.getData().toString(), Gateway.class);
//                    binding.tvaRightTurnGateway.setRightType(TitleViewWithAdd.EDIT);
//                    break;
//                case Constants.ResponseCode.DATA_NOT_EXIST:
//                    binding.tvaRightTurnGateway.setRightType(TitleViewWithAdd.ADD);
//                    break;
//            }
            LogUtil.i(TAG + "rightGateway=get====>", res.getData().toString());
            if (res.getCode() == Constants.ResponseCode.SUCCESS) {
                if (res.isDataEmpty()) {
                    binding.tvaRightTurnGateway.setRightType(TitleViewWithAdd.ADD);
                } else {
                    rightGateway = GsonUtil.GsonToListForOne(res.getData().toString(), Gateway.class);
                    binding.tvaRightTurnGateway.setRightType(TitleViewWithAdd.EDIT);
                }
            }
            if (callBackInterface != null) {
                callBackInterface.customizedFun();
            }
        });
    }

    private void initChildJump() {
        //进口道点击事件
        binding.tvaImportRoad.setIronClickListener(v -> {
            Intent intent = new Intent(this, VehicleLaneActivity.class);
            vehicleLane.setEntranceRoadId(entranceRoad.getId());
            vehicleLane.setLaneType(Type.IMPORT_LANE);
            PresentValue<VehicleLane> presentValue = new PresentValue<>(binding.tvaImportRoad.getType(), vehicleLane);
            intent.putExtra(Constants.EXTRA_KEY.VEHICLE_LANE, presentValue);
//            startActivity(intent);
            registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
                if (result.getResultCode() == Constants.RESULT_CODE.NEED_REFRESH) {
                    getVehicleLane(null);
                }
            }).launch(intent);
        });


        //出口道点击事件
        binding.tvaExitRoad.setIronClickListener(v -> {
            Intent intent = new Intent(this, VehicleLaneActivity.class);
            exitLane.setEntranceRoadId(entranceRoad.getId());
            exitLane.setLaneType(Type.EXIT_LANE);
            PresentValue<VehicleLane> presentValue = new PresentValue<>(binding.tvaExitRoad.getType(), exitLane);
            intent.putExtra(Constants.EXTRA_KEY.VEHICLE_LANE, presentValue);
//            startActivity(intent);
            registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
                if (result.getResultCode() == Constants.RESULT_CODE.NEED_REFRESH) {
                    getExitLane(null);
                }
            }).launch(intent);
        });

        //进口道展宽点击事件
        binding.tvaImportWiden.setIronClickListener(v -> {
            Intent intent = new Intent(this, WidenActivity.class);
            importWiden.setEntranceRoadId(entranceRoad.getId());
            importWiden.setLaneType(Type.IMPORT_WIDEN);
            PresentValue<Widen> presentValue = new PresentValue<>(binding.tvaImportWiden.getType(), importWiden);
            intent.putExtra(Constants.EXTRA_KEY.ENTRANCE_ROAD, presentValue);
//            startActivity(intent);
            registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
                if (result.getResultCode() == Constants.RESULT_CODE.NEED_REFRESH) {
                    if (result.getData() != null) {
                        importWiden = (Widen) result.getData().getSerializableExtra(Constants.EXTRA_KEY.ENTRANCE_ROAD);
                        binding.tvaImportWiden.setRightType(TitleViewWithAdd.EDIT);
                    }
                }
            }).launch(intent);
        });

        //出口道展宽点击事件
        binding.tvaExitWiden.setIronClickListener(v -> {
            Intent intent = new Intent(this, WidenActivity.class);
            exitWiden.setEntranceRoadId(entranceRoad.getId());
            exitWiden.setLaneType(Type.EXIT_WIDEN);
            PresentValue<Widen> presentValue = new PresentValue<>(binding.tvaExitWiden.getType(), exitWiden);
            intent.putExtra(Constants.EXTRA_KEY.ENTRANCE_ROAD, presentValue);
//            startActivity(intent);
            registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
                if (result.getResultCode() == Constants.RESULT_CODE.NEED_REFRESH) {
                    if (result.getData() != null) {
                        exitWiden = (Widen) result.getData().getSerializableExtra(Constants.EXTRA_KEY.ENTRANCE_ROAD);
                        binding.tvaExitWiden.setRightType(TitleViewWithAdd.EDIT);
                    }
                }
            }).launch(intent);
        });

        //中央分隔带点击事件
        binding.tvaCenterDivider.setIronClickListener(v -> {
            Intent intent = new Intent(this, CenterDividerActivity.class);
            centerDivider.setEntranceRoadId(entranceRoad.getId());
            PresentValue<CenterDivider> presentValue = new PresentValue<>(binding.tvaCenterDivider.getType(), centerDivider);
            intent.putExtra(Constants.EXTRA_KEY.ENTRANCE_ROAD, presentValue);
//            startActivity(intent);
            registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
                if (result.getResultCode() == Constants.RESULT_CODE.NEED_REFRESH) {
                    if (result.getData() != null) {
                        centerDivider = (CenterDivider) result.getData().getSerializableExtra(Constants.EXTRA_KEY.ENTRANCE_ROAD);
                        binding.tvaCenterDivider.setRightType(TitleViewWithAdd.EDIT);
                    }
                }
            }).launch(intent);
        });

        //人行横道点击事件
        binding.tvaSidewalk.setIronClickListener(v -> {
            Intent intent = new Intent(this, SidewalkActivity.class);
            sidewalk.setEntranceRoadId(entranceRoad.getId());
            PresentValue<Sidewalk> presentValue = new PresentValue<>(binding.tvaSidewalk.getType(), sidewalk);
            intent.putExtra(Constants.EXTRA_KEY.ENTRANCE_ROAD, presentValue);
//            startActivity(intent);
            registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
                if (result.getResultCode() == Constants.RESULT_CODE.NEED_REFRESH) {
                    if (result.getData() != null) {
                        sidewalk = (Sidewalk) result.getData().getSerializableExtra(Constants.EXTRA_KEY.ENTRANCE_ROAD);
                        binding.tvaSidewalk.setRightType(TitleViewWithAdd.EDIT);
                    }
                }
            }).launch(intent);
        });

        //非机动车道点击事件
        binding.tvaBicycleLane.setIronClickListener(v -> {
            Intent intent = new Intent(this, BicycleLaneActivity.class);
            bicycleLane.setEntranceRoadId(entranceRoad.getId());
            PresentValue<BicycleLane> presentValue = new PresentValue<>(binding.tvaBicycleLane.getType(), bicycleLane);
            intent.putExtra(Constants.EXTRA_KEY.ENTRANCE_ROAD, presentValue);
            registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
                if (result.getResultCode() == Constants.RESULT_CODE.NEED_REFRESH) {
                    if (result.getData() != null) {
                        bicycleLane = (BicycleLane) result.getData().getSerializableExtra(Constants.EXTRA_KEY.ENTRANCE_ROAD);
                        binding.tvaBicycleLane.setRightType(TitleViewWithAdd.EDIT);
                    }
                }
            }).launch(intent);
        });

        //待行区点击事件
        binding.tvaWaitingArea.setIronClickListener(v -> {
            Intent intent = new Intent(this, WaitingAreaActivity.class);
            waitingArea.setEntranceRoadId(entranceRoad.getId());
            PresentValue<WaitingArea> presentValue = new PresentValue<>(binding.tvaWaitingArea.getType(), waitingArea);
            intent.putExtra(Constants.EXTRA_KEY.ENTRANCE_ROAD, presentValue);
            registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
                if (result.getResultCode() == Constants.RESULT_CODE.NEED_REFRESH) {
                    if (result.getData() != null) {
                        waitingArea = (WaitingArea) result.getData().getSerializableExtra(Constants.EXTRA_KEY.ENTRANCE_ROAD);
                        binding.tvaWaitingArea.setRightType(TitleViewWithAdd.EDIT);
                    }
                }
            }).launch(intent);
        });

        //慢行道点击事件
        binding.tvaSlowLane.setIronClickListener(v -> {
            Intent intent = new Intent(this, SlowLaneActivity.class);
            slowLane.setEntranceRoadId(entranceRoad.getId());
            PresentValue<SlowLane> presentValue = new PresentValue<>(binding.tvaSlowLane.getType(), slowLane);
            intent.putExtra(Constants.EXTRA_KEY.ENTRANCE_ROAD, presentValue);
            registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
                if (result.getResultCode() == Constants.RESULT_CODE.NEED_REFRESH) {
                    if (result.getData() != null) {
                        slowLane = (SlowLane) result.getData().getSerializableExtra(Constants.EXTRA_KEY.ENTRANCE_ROAD);
                        binding.tvaSlowLane.setRightType(TitleViewWithAdd.EDIT);
                    }
                }
            }).launch(intent);
        });

        //交织段点击事件
        binding.tvaWeavingSection.setIronClickListener(v -> {
            Intent intent = new Intent(this, WeavingSectionActivity.class);
            weavingSection.setEntranceRoadId(entranceRoad.getId());
            PresentValue<WeavingSection> presentValue = new PresentValue<>(binding.tvaWeavingSection.getType(), weavingSection);
            intent.putExtra(Constants.EXTRA_KEY.ENTRANCE_ROAD, presentValue);
            registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
                if (result.getResultCode() == Constants.RESULT_CODE.NEED_REFRESH) {
                    if (result.getData() != null) {
                        weavingSection = (WeavingSection) result.getData().getSerializableExtra(Constants.EXTRA_KEY.ENTRANCE_ROAD);
                        binding.tvaWeavingSection.setRightType(TitleViewWithAdd.EDIT);
                    }
                }
            }).launch(intent);
        });

        //方向岛点击事件
        binding.tvaDirectionIsland.setIronClickListener(v -> {
            Intent intent = new Intent(this, DirectionIslandActivity.class);
            directionIsland.setEntranceRoadId(entranceRoad.getId());
            PresentValue<DirectionIsland> presentValue = new PresentValue<>(binding.tvaDirectionIsland.getType(), directionIsland);
            intent.putExtra(Constants.EXTRA_KEY.ENTRANCE_ROAD, presentValue);
            registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
                if (result.getResultCode() == Constants.RESULT_CODE.NEED_REFRESH) {
                    if (result.getData() != null) {
                        directionIsland = (DirectionIsland) result.getData().getSerializableExtra(Constants.EXTRA_KEY.ENTRANCE_ROAD);
                        binding.tvaDirectionIsland.setRightType(TitleViewWithAdd.EDIT);
                    }
                }
            }).launch(intent);
        });

        //左转闸道点击事件
        binding.tvaLeftTurnGateway.setIronClickListener(v -> {
            Intent intent = new Intent(this, GatewayActivity.class);
            leftGateway.setEntranceRoadId(entranceRoad.getId());
            leftGateway.setGatewayType(Type.LEFT_GATEWAY);
            Log.i("leftGateway--->", JSONObject.toJSONString(leftGateway));
            PresentValue<Gateway> presentValue = new PresentValue<>(binding.tvaLeftTurnGateway.getType(), leftGateway);
            intent.putExtra(Constants.EXTRA_KEY.ENTRANCE_ROAD, presentValue);
//            startActivity(intent);
            registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
                if (result.getResultCode() == Constants.RESULT_CODE.NEED_REFRESH) {
                    if (result.getData() != null) {
                        leftGateway = (Gateway) result.getData().getSerializableExtra(Constants.EXTRA_KEY.ENTRANCE_ROAD);
                        binding.tvaLeftTurnGateway.setRightType(TitleViewWithAdd.EDIT);
                    }
                }
            }).launch(intent);
        });

        //右转闸道点击事件
        binding.tvaRightTurnGateway.setIronClickListener(v -> {
            Intent intent = new Intent(this, GatewayActivity.class);
            rightGateway.setEntranceRoadId(entranceRoad.getId());
            rightGateway.setGatewayType(Type.RIGHT_GATEWAY);
            PresentValue<Gateway> presentValue = new PresentValue<>(binding.tvaRightTurnGateway.getType(), rightGateway);
            intent.putExtra(Constants.EXTRA_KEY.ENTRANCE_ROAD, presentValue);
//            startActivity(intent);
            registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> {
                if (result.getResultCode() == Constants.RESULT_CODE.NEED_REFRESH) {
                    if (result.getData() != null) {
                        rightGateway = (Gateway) result.getData().getSerializableExtra(Constants.EXTRA_KEY.ENTRANCE_ROAD);
                        binding.tvaRightTurnGateway.setRightType(TitleViewWithAdd.EDIT);
                    }
                }
            }).launch(intent);
        });
    }
}